<?php /* Smarty version Smarty-3.0.7, created on 2012-02-05 20:40:41
         compiled from "D:\wamp\www\ps/modules/blockadvsearch/blockadvsearch.tpl" */ ?>
<?php /*%%SmartyHeaderCode:30204f2e9bf1c36a31-66318991%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'bd0f5cf50d26e2dc92c37cc9430f329cfbae32ea' => 
    array (
      0 => 'D:\\wamp\\www\\ps/modules/blockadvsearch/blockadvsearch.tpl',
      1 => 1326126144,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '30204f2e9bf1c36a31-66318991',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>


<!-- Block AdvancedSearch module -->
<div id="advancedsearch_block_left" class="block blockadvsearch">
    <h4><?php echo smartyTranslate(array('s'=>'Advanced Search','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</h4>

    <div class="block_content">

        

        <fieldset>
            <legend><?php echo smartyTranslate(array('s'=>'Search by Attributes','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</legend>
            <form action="">
                <p>
                    <br/>
                    <?php if ($_smarty_tpl->getVariable('colors')->value){?>
                    <div><?php echo smartyTranslate(array('s'=>'Color','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</div>
                    <select id="color" style="width: 75%">
                        <?php  $_smarty_tpl->tpl_vars['color'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('colors')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['color']->key => $_smarty_tpl->tpl_vars['color']->value){
?>
                            <option value="<?php echo $_smarty_tpl->tpl_vars['color']->value['id_attribute'];?>
">
                                <?php echo $_smarty_tpl->tpl_vars['color']->value['name'];?>

                            </option>
                        <?php }} ?>
                    </select>
                <?php }?>

                <br/><br/>

                <?php if ($_smarty_tpl->getVariable('attributes')->value){?>
                    <?php  $_smarty_tpl->tpl_vars['attribname'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('attributes')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['attribname']->key => $_smarty_tpl->tpl_vars['attribname']->value){
?>
                        <?php if (count($_smarty_tpl->tpl_vars['attribname']->value['attrib'])>1){?>
                            <div class="spanattribgroup" id=<?php echo $_smarty_tpl->tpl_vars['attribname']->value['id_attrib_group'];?>
><?php echo $_smarty_tpl->tpl_vars['attribname']->value['name'];?>
</div>

                            <select style="width: 75%" class="selattrib" id=<?php echo $_smarty_tpl->tpl_vars['attribname']->value['name'];?>
>
                                <?php  $_smarty_tpl->tpl_vars['attrib'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['attribname']->value['attrib']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['attrib']->key => $_smarty_tpl->tpl_vars['attrib']->value){
?>
                                    <option value="<?php echo $_smarty_tpl->tpl_vars['attrib']->value['id_attribute'];?>
">
                                        <?php echo $_smarty_tpl->tpl_vars['attrib']->value['name'];?>

                                    </option>
                                <?php }} ?>
                            </select>
                            <br/><br/>
                        <?php }?>
                    <?php }} ?>

                <?php }?>

                <?php if ($_smarty_tpl->getVariable('categories')->value){?>


                    <div class="divcategory" id="divcategory"><?php echo smartyTranslate(array('s'=>'Category','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</div>

                    <select style="width: 75%" id="advcategory">
                        <?php  $_smarty_tpl->tpl_vars['category'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('categories')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['category']->key => $_smarty_tpl->tpl_vars['category']->value){
?>        
                            <option value="<?php echo $_smarty_tpl->tpl_vars['category']->value['id_category'];?>
">
                                <?php echo $_smarty_tpl->tpl_vars['category']->value['name'];?>

                            </option>
                        <?php }} ?>
                    </select>
                    <br/><br/>



                <?php }?>

                <a href="#" id="button_adv_search" class="exclusive" title="Search" style="margin-bottom: 5px;"><?php echo smartyTranslate(array('s'=>'Search','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</a>
                </p>
            </form>     
        </fieldset>
        
            <script type="text/javascript">
                $('#button_adv_search').click(function() {
                    var data=new Array();
                    var attribgroup = new Array();
                    $( "select.selattrib" ).each( function(index) {
                        data[index] = $( this ).attr( "id" );
                    });
                    $( "div.spanattribgroup" ).each( function(index) {
                        attribgroup[index] = $( this ).attr( "id" );
                    });
                        
                        
                    
    var colorid = $('#color').val();
    var colorname = $('#color option:selected').text();
    var advsearchlink ="<?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('advsearch.php');?>
?query_color="+colorid;
        for (var querystring in data) {
            //advsearchlink = advsearchlink +"&"+data[querystring]+"_"+attribgroup[querystring]+"="+$("#"+data[querystring]).val();
            advsearchlink = advsearchlink +"&attrib_"+attribgroup[querystring]+"="+$("#"+data[querystring]).val();
}
            advsearchlink = advsearchlink +"&advcategoryid="+$('#advcategory option:selected').val();

    $('#button_adv_search').attr('href', advsearchlink);
    //window.location.replace(advsearchlink);
                    });
            </script>
        
        
        
        
        <!-- Block search module TOP -->
        <div id="search_block_top">
            <fieldset>
                <legend><?php echo smartyTranslate(array('s'=>'Reference','mod'=>'blockadvsearch'),$_smarty_tpl);?>
</legend>
                <form method="get" action="<?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('search.php');?>
" id="searchbox">
                    <p>
                        <label for="search_query_top"><!-- image on background --></label>
                        <input type="hidden" name="orderby" value="position" />
                        <input type="hidden" name="orderway" value="desc" />
                        <input class="search_query" type="text" id="search_query_top" name="search_query" value="<?php if (isset($_GET['search_query'])){?><?php echo stripslashes(htmlentities($_GET['search_query'],$_smarty_tpl->getVariable('ENT_QUOTES')->value,'utf-8'));?>
<?php }?>" />
                        <input type="submit" name="submit_search" value="<?php echo smartyTranslate(array('s'=>'Search','mod'=>'blockadvsearch'),$_smarty_tpl);?>
" class="exclusive" style="margin-top: 7px;margin-bottom: 5px;margin-left: 11%;" />
                    </p>
                </form>

            </fieldset>
        </div>
        <?php if ($_smarty_tpl->getVariable('instantsearch')->value){?>
            <script type="text/javascript">
            // <![CDATA[
                
                    function tryToCloseInstantSearch() {
                            if ($('#old_center_column').length > 0)
                            {
                                    $('#center_column').remove();
                                    $('#old_center_column').attr('id', 'center_column');
                                    return false;
                            }
                    }
		
                    instantSearchQueries = new Array();
                    function stopInstantSearchQueries(){
                            for(i=0;i<instantSearchQueries.length;i++) {
                                    instantSearchQueries[i].abort();
                            }
                            instantSearchQueries = new Array();
                    }
		
                    $("#search_query_top").keyup(function(){
                            if($(this).val().length > 0){
                                    stopInstantSearchQueries();
                                    instantSearchQuery = $.ajax({
                                    url: '<?php if ($_smarty_tpl->getVariable('search_ssl')->value==1){?><?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('search.php',true);?>
<?php }else{ ?><?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('search.php');?>
<?php }?>',
                                    data: 'instantSearch=1&id_lang=<?php echo $_smarty_tpl->getVariable('cookie')->value->id_lang;?>
&q='+$(this).val(),
                                    dataType: 'html',
                                    success: function(data){
                                            if($("#search_query_top").val().length > 0)
                                            {
                                                    tryToCloseInstantSearch();
                                                    $('#center_column').attr('id', 'old_center_column');
                                                    $('#old_center_column').after('<div id="center_column">'+data+'</div>');
                                                    $("#instant_search_results a.close").click(function() {
                                                            $("#search_query_top").val('');
                                                            return tryToCloseInstantSearch();
                                                    });
                                                    return false;
                                            }
                                            else
                                                    tryToCloseInstantSearch();
                                            }
                                    });
                                    instantSearchQueries.push(instantSearchQuery);
                            }
                            else
                                    tryToCloseInstantSearch();
                    });
            // ]]>
                
            </script>
        <?php }?>

        <?php if ($_smarty_tpl->getVariable('ajaxsearch')->value){?>
            <script type="text/javascript">
            // <![CDATA[
                
                    $('document').ready( function() {
                            $("#search_query_top")
                                    .autocomplete(
                                            '<?php if ($_smarty_tpl->getVariable('search_ssl')->value==1){?><?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('search.php',true);?>
<?php }else{ ?><?php echo $_smarty_tpl->getVariable('link')->value->getPageLink('search.php');?>
<?php }?>', {
                                                    minChars: 3,
                                                    max: 10,
                                                    width: 500,
                                                    selectFirst: false,
                                                    scroll: false,
                                                    dataType: "json",
                                                    formatItem: function(data, i, max, value, term) {
                                                            return value;
                                                    },
                                                    parse: function(data) {
                                                            var mytab = new Array();
                                                            for (var i = 0; i < data.length; i++)
                                                                    mytab[mytab.length] = { data: data[i], value: data[i].cname + ' > ' + data[i].pname };
                                                            return mytab;
                                                    },
                                                    extraParams: {
                                                            ajaxSearch: 1,
                                                            id_lang: <?php echo $_smarty_tpl->getVariable('cookie')->value->id_lang;?>

                                                    }
                                            }
                                    )
                                    .result(function(event, data, formatted) {
                                            $('#search_query_top').val(data.pname);
                                            document.location.href = data.product_link;
                                    })
                    });
                
            // ]]>
            </script>
        <?php }?>
        <!-- /Block search module TOP -->

        
    </div>
</div>
<!-- /Block AdvancedSearch module -->
